<HTML>

<HEAD>
<TITLE>Motif Multi-Document Interface (MDI)</TITLE>
<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>

<CENTER>
<IMG SRC="pics/mdi.gif" ALT="[Class Structure]">
<P><H2>
<B>
The Motif Multi-Document Interface
</B>
</H2>
</CENTER>

<P>
The Motif Multi-Document Interface (MDI) is a collection of C++ classes
that emulates the behavior of the Multi-Document Interface in Microsoft
Windows.  The MDI framework allows a user to view multiple documents (windows)
constrained to a single parent window.

<P>
<HR SIZE = 4>

<P>
<B>
C<FONT SIZE=-1>LASS</FONT>
S<FONT SIZE=-1>TRUCTURE:</FONT>
</B>

<P>
<IMG SRC="pics/classes.gif" ALT="[Class Structure]">

<BR>
Figure 1.  Inheritance Graph for MDI classes

<P>
The <I>XsMDICanvas</I> is a self-contained component used to display and manage
any number of child document windows.  All documents windows are derived from
the abstract base-class <I>XsMDIWindow</I>.  To get the Motif-like functionality,
document windows should be derived from the <I>XsMotifWindow</I> class.

<P>
<HR SIZE = 4>

<P>
<B>
E<FONT SIZE=-1>XAMPLE:</FONT> 
</B>

<P>
The process of building and displaying a Multi-Document Interface using MDI
consists of the following steps:

<OL>
<LI>Creating the application document(s)</LI>
<LI>Creating the MDI canvas</LI>
<LI>Adding the document(s) to the canvas</LI>
</OL>

<PRE>

#include "XsMDICanvas.h"
#include "XsMotifWindow.h"

// Application document (derived from XsMotifWindow)

class MyDocument : public XsMotifWindow {
   public:
      MyDocument (const char *name);
      virtual ~MyDocument ( );
   protected:
      virtual void _buildClientArea (Widget parent);
};
      
void createCanvas (Widget parent) {

// Create documents

   MyDocument *doc1 = new MyDocument ("doc1");
   MyDocument *doc2 = new MyDocument ("doc2");
   
// Create the canvas

   XsMDICanvas *canvas = new XsMDICanvas ("canvas", parent);
   
// Add documents to canvas

   canvas->add (doc1);
   canvas->add (doc2);

// Show the canvas

   canvas->show ( );
}
   
</PRE>

<P>
In this example, the application document <I>MyDocument</I> is derived
from <I>XsMotifWindow</I>.  This provides a Motif-like window suitable for
use with the <I>XsMDICanvas</I>.

<P>
Next, two <I>MyDocument</I> objects are created along with the <I>XsMDICanvas</I>.
The two documents are then added to the canvas using the <I>add</I>
member-function of the canvas.  Lastly, the canvas is shown (managed)
using the <I>show</I> member-function.

<P>
Creating the document <I>MyDocument</I> does not automatically create any
widgets.  Rather, it only initializes internal variables.  The widgets are
not created until the document is added to the canvas.  The <I>XsMDICanvas</I>
is responsible for calling <I>XsMotifWindow::_buildClientArea()</I> at an
appropriate time.  In this member-function, the application can create the
actual contents of the document.

<P>
The member-function <I>_buildClientArea</I> is passed a widget to be used as
the parent of the document contents.  This parent widget is an unmanaged
<I>XmForm</I> widget.  The application is free to create whatever contents
it needs as a child of the <I>XmForm</I> parent.

<P>
<HR SIZE = 4>

<P>
<B>
C<FONT SIZE=-1>LASS</FONT>
R<FONT SIZE=-1>EFERENCES:</FONT>
</B>

<P>
Of the classes in the MDI package, only the following should be of
interest to MDI library users:

<UL>
<LI> <A HREF="canvas.html"> XsMDICanvas </A> </LI>
<LI> <A HREF="mwindow.html"> XsMotifWindow </A> </LI>
</UL>

<P>
<HR SIZE = 4>

<P>
<B>
E<FONT SIZE=-1>XPLORING</FONT>
R<FONT SIZE=-1>ESOURCES:</FONT>
</B>

<P>
The MDI classes support a number of different X-resources (please refer
to the class manual pages for complete details).  In order to get a feel
for the customization capabilities of the MDI library, try running the
test program (<I>MDItest</I>) with the following command-line options:

<DL>
<DD>MDItest -xrm "*showBorder:false"</DD>
<DD>MDItest -xrm "*showTitle:false" -xrm "*showResize:false"</DD>
<DD>MDItest -xrm "*showMenu:false" -xrm "*showMaximize:false"</DD>
<DD>MDItest -xrm "*borderSize:4" -xrm "*buttonSize:14"</DD>
<DD>MDItest -xrm "*lowerOnIconify:true" -xrm "*title:Hello World"</DD>
</DL>

<P>
<HR SIZE = 4>

<P>
<B>
A<FONT SIZE=-1>DDITIONAL</FONT>
I<FONT SIZE=-1>INFORMATION:</FONT>
</B>

<P>
The test program <I>MDItest.C</I> gives a complete example of an MDI
application.  It should serve as a good reference/example of the MDI library.

</BODY>
</HTML>


